package com.chezhujie.www.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chezhujie.www.domain.IP;
import com.chezhujie.www.persistence.IPMapper;
import com.sys.core.exception.ClassCheckException;
import com.sys.user.base.service.BaseService;


/**
 * 店铺信息
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class IPService extends BaseService<IP>{
    @Autowired
    private IPMapper ipMapper;

    @Autowired
    public void setBaseMapper(IPMapper ipMapper) {
        this.baseMapper = ipMapper;
    }


    public void checkEntity(IP ip) throws ClassCheckException {
        if(ip.getIpId()!=null&&ip.getIpId().length()>19){
            throw new ClassCheckException("店铺信息主键不能超过19个字符");
        }
        if(ip.getAddress()!=null&&ip.getAddress().length()>50){
            throw new ClassCheckException("店铺信息IP地址不能超过50个字符");
        }
    }
    public void checkListEntity(List<IP> listIP) throws ClassCheckException {

        for (IP ip : listIP) {
            checkEntity(ip);
        }

    }


	public int selectCountByIp(Map<String, Object> map){
		return ipMapper.selectCountByIp(map);
	}
}
